package cn.stylefeng.guns.modular.hxl.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.hxl.entity.VHxlPickDaySorterSum;
import cn.stylefeng.guns.modular.hxl.mapper.VHxlPickDaySorterSumMapper;
import cn.stylefeng.guns.modular.hxl.model.params.VHxlPickDaySorterSumParam;
import cn.stylefeng.guns.modular.hxl.model.result.VHxlPickDaySorterSumResult;
import  cn.stylefeng.guns.modular.hxl.service.VHxlPickDaySorterSumService;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * VIEW 服务实现类
 * </p>
 *
 * @author zhangzh
 * @since 2025-06-30
 */
@Service
public class VHxlPickDaySorterSumServiceImpl extends ServiceImpl<VHxlPickDaySorterSumMapper, VHxlPickDaySorterSum> implements VHxlPickDaySorterSumService {

    @Override
    public void add(VHxlPickDaySorterSumParam param){
        VHxlPickDaySorterSum entity = getEntity(param);
        this.save(entity);
    }

    @Override
    public void delete(VHxlPickDaySorterSumParam param){
        this.removeById(getKey(param));
    }

    @Override
    public void update(VHxlPickDaySorterSumParam param){
        VHxlPickDaySorterSum oldEntity = getOldEntity(param);
        VHxlPickDaySorterSum newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        this.updateById(newEntity);
    }

    @Override
    public VHxlPickDaySorterSumResult findBySpec(VHxlPickDaySorterSumParam param){
        return null;
    }

    @Override
    public List<VHxlPickDaySorterSumResult> findListBySpec(VHxlPickDaySorterSumParam param){
        return this.baseMapper.customList(param);
    }

    @Override
    public LayuiPageInfo findPageBySpec(VHxlPickDaySorterSumParam param,String condition){
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.customPageList(pageContext, param,condition);
        return LayuiPageFactory.createPageInfo(page);
    }

    @Override
    public LayuiPageInfo listUser(VHxlPickDaySorterSumParam param) {
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.listUser(pageContext, param);
        return LayuiPageFactory.createPageInfo(page);
    }

    @Override
    public LayuiPageInfo listWarehouse(VHxlPickDaySorterSumParam param) {
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.listWarehouse(pageContext, param);
        return LayuiPageFactory.createPageInfo(page);
    }


    private Serializable getKey(VHxlPickDaySorterSumParam param){
        return null;
    }

    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }

    private VHxlPickDaySorterSum getOldEntity(VHxlPickDaySorterSumParam param) {
        return this.getById(getKey(param));
    }

    private VHxlPickDaySorterSum getEntity(VHxlPickDaySorterSumParam param) {
        VHxlPickDaySorterSum entity = new VHxlPickDaySorterSum();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }

}
